import { Space, Popconfirm, Button } from 'antd';
import ProTableComp, { type ColumnsType, type ToolsType } from '@/components/ProTableComp';
import { adminUserRoles } from '@/api/modules/adminUser';

import "./index.less";

const Page = () => {
	const columns: ColumnsType[] = [{
		title: '角色名称',
		dataIndex: 'name',
		width: '180',
	}, {
		title: '创建人',
		dataIndex: 'admin_name',
		width: '180',
	}, {
		title: '创建时间',
		dataIndex: 'create_time',
		width: '180',
	}, {
		title: '操作',
		dataIndex: 'h',
		hideSearch: true,
		width: '180',
		fixed: 'right',
		render: (_, record) => (
			<Space>
				<Button type="primary">编辑</Button>
				<Popconfirm
					title="确定删除吗?"
					onConfirm={() => {
						console.log(record);
					}}
				/>
			</Space>
		)
	}];

	const tools: ToolsType[] = [
		{
			type: 'button',
			text: '新增',
			compProps: {
				type: 'primary',
				onClick: () => {
					console.log('新增');
				}
			}
		}
	];

	return (
		<div className="card content-box admin-roles">
			<ProTableComp
				tableName="角色管理"
				request={adminUserRoles}
				columns={columns}
				tools={tools}
			/>
		</div>
	);
};

export default Page;
